package com.zycfc.zsf.boot.distributedlock.configuration;

import org.springframework.boot.context.properties.*;
import org.springframework.core.env.*;
import org.springframework.beans.factory.annotation.*;
import javax.annotation.*;

@ConfigurationProperties(prefix = "zsf.boot.distributedlock")
public class DistributedLockProperties
{
    public static final String PREFIX = "zsf.boot.distributedlock";
    private String applicationName;
    private String namespace;
    @Autowired
    private Environment env;
    private String mode;
    private String zkServers;
    private static String appName;
    private static String zkAddress;
    
    @PostConstruct
    public void init() {
        if (null != this.env && (null == this.namespace || this.namespace.trim().length() == 0)) {
            this.applicationName = this.env.getProperty("spring.application.name");
            this.namespace = this.env.getProperty("zsf.all.namespace");
            DistributedLockProperties.appName = this.applicationName;
            DistributedLockProperties.zkAddress = this.zkServers;
        }
    }
    
    private static void setAppName(final String appName) {
        DistributedLockProperties.appName = appName;
    }
    
    private static void setZkAddress(final String zkAddress) {
        DistributedLockProperties.zkAddress = zkAddress;
    }
    
    public static String getAppName() {
        return DistributedLockProperties.appName;
    }
    
    public static String getZkAddress() {
        return DistributedLockProperties.zkAddress;
    }
    
    public DistributedLockProperties() {
        this.mode = "redis";
    }
    
    public String getApplicationName() {
        return this.applicationName;
    }
    
    public String getNamespace() {
        return this.namespace;
    }
    
    public Environment getEnv() {
        return this.env;
    }
    
    public String getMode() {
        return this.mode;
    }
    
    public String getZkServers() {
        return this.zkServers;
    }
    
    public void setApplicationName(final String applicationName) {
        this.applicationName = applicationName;
    }
    
    public void setNamespace(final String namespace) {
        this.namespace = namespace;
    }
    
    public void setEnv(final Environment env) {
        this.env = env;
    }
    
    public void setMode(final String mode) {
        this.mode = mode;
    }
    
    public void setZkServers(final String zkServers) {
        this.zkServers = zkServers;
    }
    
    @Override
    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof DistributedLockProperties)) {
            return false;
        }
        final DistributedLockProperties other = (DistributedLockProperties)o;
        if (!other.canEqual(this)) {
            return false;
        }
        final Object this$applicationName = this.getApplicationName();
        final Object other$applicationName = other.getApplicationName();
        Label_0065: {
            if (this$applicationName == null) {
                if (other$applicationName == null) {
                    break Label_0065;
                }
            }
            else if (this$applicationName.equals(other$applicationName)) {
                break Label_0065;
            }
            return false;
        }
        final Object this$namespace = this.getNamespace();
        final Object other$namespace = other.getNamespace();
        Label_0102: {
            if (this$namespace == null) {
                if (other$namespace == null) {
                    break Label_0102;
                }
            }
            else if (this$namespace.equals(other$namespace)) {
                break Label_0102;
            }
            return false;
        }
        final Object this$env = this.getEnv();
        final Object other$env = other.getEnv();
        Label_0139: {
            if (this$env == null) {
                if (other$env == null) {
                    break Label_0139;
                }
            }
            else if (this$env.equals(other$env)) {
                break Label_0139;
            }
            return false;
        }
        final Object this$mode = this.getMode();
        final Object other$mode = other.getMode();
        Label_0176: {
            if (this$mode == null) {
                if (other$mode == null) {
                    break Label_0176;
                }
            }
            else if (this$mode.equals(other$mode)) {
                break Label_0176;
            }
            return false;
        }
        final Object this$zkServers = this.getZkServers();
        final Object other$zkServers = other.getZkServers();
        if (this$zkServers == null) {
            if (other$zkServers == null) {
                return true;
            }
        }
        else if (this$zkServers.equals(other$zkServers)) {
            return true;
        }
        return false;
    }
    
    protected boolean canEqual(final Object other) {
        return other instanceof DistributedLockProperties;
    }
    
    @Override
    public int hashCode() {
        final int PRIME = 59;
        int result = 1;
        final Object $applicationName = this.getApplicationName();
        result = result * 59 + (($applicationName == null) ? 43 : $applicationName.hashCode());
        final Object $namespace = this.getNamespace();
        result = result * 59 + (($namespace == null) ? 43 : $namespace.hashCode());
        final Object $env = this.getEnv();
        result = result * 59 + (($env == null) ? 43 : $env.hashCode());
        final Object $mode = this.getMode();
        result = result * 59 + (($mode == null) ? 43 : $mode.hashCode());
        final Object $zkServers = this.getZkServers();
        result = result * 59 + (($zkServers == null) ? 43 : $zkServers.hashCode());
        return result;
    }
    
    @Override
    public String toString() {
        return "DistributedLockProperties(applicationName=" + this.getApplicationName() + ", namespace=" + this.getNamespace() + ", env=" + this.getEnv() + ", mode=" + this.getMode() + ", zkServers=" + this.getZkServers() + ")";
    }
}
